package cn.yomigaeri.warn.consumer;

import cn.yomigaeri.common.entity.dto.SignalDTO;
import cn.yomigaeri.common.entity.dto.WarnDTO;
import cn.yomigaeri.common.entity.po.Warn;
import cn.yomigaeri.warn.mapper.WarnMapper;
import cn.yomigaeri.warn.service.WarnSignalService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;


/**
 * @ClassName: SignalConsumer
 * @Package: cn.yomigaeri.upload.consumer
 * @Description:
 * @Author Yomigaeri
 * @Create 2025/6/4 21:45
 * @Version 1.0
 */
@Service
@Slf4j
@RequiredArgsConstructor
@RocketMQMessageListener(
        topic = "warnToSave",
        consumerGroup = "warn-consumer"
)
public class WarnConsumer implements RocketMQListener<WarnDTO> {

    private final WarnMapper  warnMapper;

    @Override
    public void onMessage(WarnDTO warnDTO) {
        Warn warn = new Warn();
        BeanUtils.copyProperties(warnDTO,  warn);
        warnMapper.insert(warn);
    }
}
